<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('oss_files', function (Blueprint $table) {
            $table->id();
            $table->integer('site_id')->nullable()->unsigned()->default(0)->comment('服务商id');
            $table->string('original_file_name', 255)->nullable()->comment('原始文件名称');
            $table->string('file_name', 255)->nullable()->comment('oss文件名称');
            $table->string('file_path', 500)->nullable()->comment('oss文件路径');
            $table->bigInteger('file_size')->nullable()->unsigned()->default(0)->comment('文件大小单位:字节');
            $table->string('file_type', 50)->nullable()->comment('文件类型');
            $table->char('is_clear',1)->nullable()->default('f')->comment('文件是否需要清理t:是f:否');
            $table->dateTime('expired_at')->nullable()->comment('过期时间');
            $table->dateTime('created_at')->nullable();
            $table->dateTime('updated_at')->nullable();
            $table->dateTime('deleted_at')->nullable();
            $table->index('site_id', 'idx_siteId');
            $table->index('expired_at', 'idx_expiredAt');
            $table->index(['is_clear','expired_at'], 'idx_isClearExpiredAt');
            $table->comment('oss上传文件表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('oss_files');
    }
};
